from flask import Flask,request,render_template
from wtforms import Form,StringField
from wtforms.validators import Length
app=Flask(__name__)

@app.route('/')
def first():
    return '首页'
class RegisterForm(Form):
    uname=StringField(validators=[Length(min=2,max=10,message='用户名长度必须在2-10之间')])
    password=StringField(validators=[Length(min=2,max=10,message='用户名长度必须在2-10之间')])

@app.route('/register/',methods=["POSt","GET"])
def register():
    if request.method == "GET":
        return render_template('register.html')
    else:
        form = RegisterForm(request.form)
        if form.validate():
            return "验证陈工"
        else:
            return f'{form.errors}验证失败哦'
if __name__=='__main__':
    app.run(debug=True)